﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace WcfEventReceiveConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8001/MeterEvents");
            ServiceHost selfHost = new ServiceHost(typeof(MeterEventService), baseAddress);
            ServiceMetadataBehavior smdb = new ServiceMetadataBehavior();
            smdb.HttpGetEnabled = true;
            selfHost.Description.Behaviors.Add(smdb);
            selfHost.Open();

            Console.WriteLine("Metere Event Serivce is up!!");
            Console.ReadLine();

            selfHost.Close();
        }
    }

    [ServiceContract]
    public interface IMeterEventService
    {
        [OperationContract]
        void SubmitMeterEvent(string MeterId, double Value, DateTime Timestamp);
    }

    public class MeterEventService : IMeterEventService
    {
        void IMeterEventService.SubmitMeterEvent(string MeterId, double Value, DateTime Timestamp)
        {
            Console.WriteLine("MeterID: {0}, Value: {1}, Date/Time: {2}", MeterId, Value, Timestamp);
        }
    }
}
